<?php

namespace App\Models;

use Slowlyo\OwlAdmin\Models\BaseModel as Model;
use Slowlyo\OwlAdmin\Models\AdminUser;

/**
 * C业务管理
 */
class CustomerBu extends Model
{

	protected $table = 'customer_bus';
	protected static function boot()
	{
		parent::boot();

		static::creating(function ($model) {
			$model->created_at = date('Y-m-d H:i:s');
			$model->updated_at = date('Y-m-d H:i:s');
			$model->operator_uid = admin_user()->id;
			$model->editor_uid = admin_user()->id;
		});

		static::updating(function ($model) {
			$model->updated_at = date('Y-m-d H:i:s');
			$model->editor_uid = admin_user()->id;
		});
	}

	public function fcustomer()
	{
		return $this->belongsTo(Fcustomer::class, 'fcustomer_id', 'id');
	}
	
	public function sign_company()
	{
		return $this->belongsTo(Company::class, 'sign_company', 'id');
	}

	public function idcnode()
	{
		return $this->belongsTo(Idcnode::class, 'idcnode_id', 'id');
	}

	public function operator()
	{
		return $this->belongsTo(AdminUser::class, 'operator_uid', 'id');
	}
}